#include<cstdio>
#include<algorithm>

using namespace std;

const int N=1e5+10;

struct Range{
	int l;
	int r;
}range[N];


bool cmp(Range a,Range b){
	return a.r<b.r;
}


int main()
{
	int n;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%d%d",&range[i].l,&range[i].r);
	}
	
	sort(range,range+n,cmp);
	
	int ans=1,sum=range[0].r;
	for(int i=0;i<n;i++){
		if(sum<range[i].l){
			ans++;
			sum=range[i].r;
		}
	}
	
	printf("%d",ans);
	
	return 0;
}
